package com.xyh.mapper;

import com.xyh.entity.YxcAmount;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface YxcAmountMapper {
    @Insert("insert yxc_amount(car_number,owner_telephone,start_time) values(#{car_number},#{owner_telephone},#{start_time})")
    int addStartAmount(YxcAmount yxcAmount);

    @Select("select * from yxc_amount where owner_telephone = #{owner_telephone} and is_pay = 0 and flag = 1")
    YxcAmount getAmountByPhone(@Param("owner_telephone") String login_telephone);

    @Select("select * from yxc_amount where amount_id = #{amount_id} and flag = 1")
    YxcAmount getAmountById(@Param("amount_id") int amount_id);

    @Update("update yxc_amount set end_time = #{end_time} ,total_time = #{total_time} ,pay_amount = #{pay_amount} ,is_pay = 1,use_yhq = #{use_yhq},what_yhq = #{what_yhq},sjjf_time = #{sjjf_time} ,sjjf_telephone = #{sjjf_telephone},sjjf_pay = #{sjjf_pay} \n" +
            " where amount_id = #{amount_id} ")
    int updateEndAmount(YxcAmount yxcAmount);

    @Update("update yxc_amount set end_time = #{end_time} ,total_time = #{total_time} ,pay_amount = 0 ,is_pay = 1,use_yhq = 0,sjjf_time = #{sjjf_time} ,sjjf_telephone = #{sjjf_telephone},sjjf_pay = 0 \n" +
            " where amount_id = #{amount_id} ")
    int updateEndAmountFree(YxcAmount yxcAmount);

    @Select("select * from yxc_amount ${whereCondition}")
    List<YxcAmount> getAountByPhoneAndPage(@Param("whereCondition") String whereCondition);

    @Update("update yxc_amount set flag = 0 where amount_id = #{amount_id}")
    int deleteByAmountId(@Param("amount_id") int amount_id);

    @Select("select * from yxc_amount where car_number = #{car_number} and is_pay = 0 and flag = 1")
    YxcAmount getAmountByCarNumber(@Param("car_number") String car_number);
}
